import { RespCode } from '@/util/ResponseResultBuilder'

export class SystemException extends Error {
  /**
   * http响应状态码
   * @private
   */
  private httpStatusCode: number
  /**
   * 业务状态码
   * @private
   */
  private bizCode: RespCode
  /**
   * 显示给客户端的自定义异常信息
   * @private
   */
  private errorMsg: string

  constructor(expMsg: string, bizCode: RespCode = 400, httpStatusCode = 200) {
    super(
      `bizCode: ${bizCode}, httpStatusCode: ${httpStatusCode}, expMsg: ${expMsg}`
    )
    this.httpStatusCode = httpStatusCode
    this.bizCode = bizCode
    this.errorMsg = expMsg
  }

  public getHttpStatusCode(): number {
    return this.httpStatusCode
  }

  public getBizCode(): RespCode {
    return this.bizCode
  }

  public getErrorMsg(): string {
    return this.errorMsg
  }
}
